<template>
  <h2>👶孙组件</h2>
  <div>{{ car }}</div>
  <div>{{ money }}</div>
  <button @click="changeMoney">点击</button>
</template>

<script setup lang="ts">
import { inject, Ref } from 'vue'

// provide('key', value)         提供数据
// const value = inject('key')   获取数据
const money = inject<Ref<number>>('money')
const car = inject<Ref<string>>('car')
const changeMoney = () => {
  // console.log('获取到真实值', money?.value)
  if (money) {
    money.value -= 100
  }
}
</script>
